import { EventBus } from "@/utils/EventBus";

try {
    // 修改颜色
    let colorDiv = document.querySelectorAll('.col_group>div')
    colorDiv.forEach(div => {
        div.addEventListener("click", () => {
            let colorStr = div.dataset.col
            EventBus.getInstance().emit('changeCarColor', colorStr)
        })
    })

    // 修改贴膜
    let filmDiv = document.querySelectorAll('.coat_group>div')
    filmDiv.forEach(div => {
        div.addEventListener("click", () => {
            let coStr = div.dataset.co
            // 修改贴膜
            EventBus.getInstance().emit('changeCarCoat', coStr)
            // 计算价格
            EventBus.getInstance().emit('celPrice')
        })
    })

    // 切换场景
    let sceneDiv = document.querySelectorAll('.scene_group > div')
    sceneDiv.forEach(div => {
        div.addEventListener("click", () => {
            let poi = div.dataset.poi
            EventBus.getInstance().emit('changeSky', poi)
        })
    })

    // 修改视角
    let angleView = document.querySelectorAll('.look_group > div')
    angleView.forEach(div => {
        div.addEventListener("click", () => {
            let viewName = div.dataset.po
            // 视角名称 -> 事件总线 -> Car类
            EventBus.getInstance().emit('changeCarAngleView', viewName)
        })
    })

} catch (error) {
    console.log(error, 'error');
}